Skip to content
main
Switch branches/tags
jam0001/KerLang/
jam0001/KerLang/

Latest commit

* init

* Basic AST

* KL IR

* uwu

* BURNING C++ 'CAUSE OCAML IS BETTER

* SELF + pretty printing

* renaming

* fix recursive calls in lk_IR

* better ast pp

* wip on the parser + new ideas

* glkc

* wip on parser

* Added random number generator

* Oops

* uwu

* its ok now

* New parser

* fix build issues with Int32

* minimal CLI

* colored error report

* add separators in the lexer

* kl_parsing.ml

* Minimal Readme

* Code gen is on the way

* manual

* Build expression from tokens (wip)

* Small example

* Code gen is good now

* Code gen is really good this time

* kl_schemas

* document kl_schemas

* reformatting & renaming kl_2ml.ml

* Update expression parser

* dump ml code in out_channels

* Update expression parser

* Update expression parser

* Update expression parser

* h

* Update expression parser, add parse_file

* Update example

* Renaming a few things here and there

* clean kl_expr (part 1 xD)

* renaming in lk_expr

* Reorder if arguments, fix sum keyword

* Remove parse_file

* kl_codegen

* Expr statement pretty printer

* Renamed things in a pp

* print compilation results

* Code gen rec is now generated if useful

* print usage

* Add singular keywords

* Use position instead of lexbuf in print_position

* Add print_synta_error

* Fix kl_2ml

* Add syntax errors during parsing

* realizers

* Add warning during parsing

* Realizers functor

* Improve warning for return value

* formatting kl_constraints_pp

* Parse variable name with spaces

* Add : as a separator

* Add error when parsing unknown variable name

* cli

* Added python backend

* realizer selection

* commit

* Python backend moment

* Add print_compile_error

* fix all the op related shit

* Update example

* Replace value operation with expr operation, add complete_holes (yay) compile yolo

* Remove unused files

* Fix function name

* Restore example

* i

* kl_errors

* Restore examples (i hope)

* u

* ignore gklc outputs

* Started to write the manual

* Update sep grammar

* Manage errors with kl_errors

* commit moment

* Added C backend

* Add fibonacci example (yay)

* Added main call

* Remove useless files

* print compile info

* h

* Allow orphan comments, make semicolons optional, fix typos

* Add useless example

* Added dev_error

* u

* j

* enchance info report

* print realization

* Extension list

* Replace intentional failwith with custom exceptions

* catching errors

* Update README example

* flookup and elookup

* huwu

* y

* lookups

* fix declarations printing

* Main parameters now raises a nice error

* ?

* -x option

* Add show function

* Add 'shows' instruction to display an expression

* Update fibo example

* Allow to display multiple expressions with the same instruction

* makefile

* Index arguments starting from 0 in pretty printer

* Twice

* update README

* Reamdme

* wip on the manual

* Check function name during parsing

* manua

* rebuild

Co-authored-by: anima-libera <anim.libera@gmail.com>
Co-authored-by: Igor Martayan <igor@martayan.org>
c81e845

Git stats

Files

Permalink
Failed to load latest commit information.

KerLang

KerLang is an innovative programming language built with love <3 for the Langjam0001. It features a state of the art compiler named "The Glorious KerLang Compiler" (also known as the Glorious Ker-Lann Compiler but who cares ?) and a first-class support for comment-oriented programming.

What on Earth is comment-oriented programming ?

Writing good comments is CS 101. But we all know how hard it is to stay focus on writing comments and documentation. Comment-oriented programming propose a game changing approach to software development : instead of writing the code and then writing comments, KerLang enforce you to over-comment your code and the compiler generate the code for you !

Here is an example program :

/*
	This function takes 1 argument,
	it returns the product of argument 1 and 2.
*/
function twice;

When executing a program written in KerLang, you first ask the compiler to generate code. The KerLang compiler is capable of producing code for the following languages:

  • Python3
  • C
  • OCaml

To generate code, one can simply specify an output file. The KerLang compiler will automatically decide which language to target based on the file extension. For example the command gklc twice.kl -o twice.ml will generate the following ocaml file :

(*----------------------------------------------------*)
(* This code is generated by the KerLang compiler and *)
(* is not intended to be manually edited              *)
(*----------------------------------------------------*)

let twice = (fun x0 ->
  (( * ) 
    x0
    2))

If you don't want to generate source code it is possible to execute it directly too ! To do so you just need to provide a main function in your sources, the execution of the main function can be requested using the -x option of the compiler.

Here is an example using a main function :

/*
	This function takes 1 argument,
	it returns the product of argument 1 and 2.
*/
function twice;

/*
	It uses 8.
	It shows the application of twice on 3.
*/
function main;

If compiled into C, Ocaml or Python3, such program will call the main function automatically.

More about KerLang

To know more about KerLang, examples are ready to be run in the examples/ folder. The KerLang manual is also available as a pdf file.

Build instructions

KerLang is crafted in pure OCaml (version 4.11.1) with no dependencies other than dune as its build system.

Installing OCaml and dune

To install a suitable version of OCaml from scratch, the following commands should do the job on any OS

bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)"
opam init
eval $(opam env)
opam switch create 4.11.1
opam install dune

Compiling the project

Compiling the Glorious KerLang Compiler is as simple as typing make at the project's root !